/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vale.miniDOM;

import java.util.Vector;
import vale.util.StrOp;

/**
 *
 * @author juan
 */
public final class XmlElement {

    private Vector<XmlElement> elements;
    private XMLAttribute[] atts;
    private Vector<String> content;
    private String name;

    public XmlElement(String tag) {
        this.content = new Vector<String>();
        this.elements = new Vector<XmlElement>();
        this.atts = XMLAttribute.getAttributtes(tag);
        if (tag.endsWith("/>")) {
            this.name = StrOp.getNameOfTag(tag, "<", "/>");
        } else {
            this.name = StrOp.getNameOfTag(tag, "<", ">");
        }
    }

    public String[] getContent(){
        String[] array=new String[this.content.size()];
        return this.content.toArray(array);
    }

    public XmlElement[] getElements() {
        XmlElement[] array = new XmlElement[this.elements.size()];
        return this.elements.toArray(array);
    }

    public String getName() {
        return this.name;
    }

    public XMLAttribute[] getAttributes() {
        return this.atts;
    }

    public void addContent(String content) {
        this.content.add(content);
    }

    public void addElement(XmlElement element) {
        this.elements.add(element);
    }
}
